import React from 'react';
import {inject, observer} from 'mobx-react';

import E9Login from './e9login/E9Login';

@inject('portalLoginStore')
@observer
class Login extends React.Component {
    constructor(props) {
        super(props)
    }

    componentWillMount() {
        const {location = {}, portalLoginStore} = this.props;
        const {query = {}} = location;
        portalLoginStore.getLoginInfo(query);
    }

    componentWillReceiveProps(nextProps) {
        const {portalLoginStore} = this.props;
        const {location = {}} = nextProps;
        const {query = {}} = location;
        portalLoginStore.setQueryParams(query);
    }

    render() {
        const {portalLoginStore} = this.props;
        const {state} = portalLoginStore;
        const {id} = state;

        if (id) {
            return <E9Login/>;
        } else {
            return <div/>;
        }
    }
}

export default Login;
